import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

export const routes = [
  ...require('./base').default
  // ...require('./rules').default
]

const router = new Router({
  routes
})

router.beforeEach((to, from, next) => {
  // next()
  console.log('我的的token',localStorage.getItem('token'))
  // return
  const toLogin = !!localStorage.getItem('token')
  if (to.path === '/login') {
    toLogin ? next('/') : next()
    // next()
  } else {
    toLogin ? next('/') : next('/login')
    // next()
  }
})

export default router
